using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;


namespace Karasoft.Web.UI
{
    /// <summary>
    /// Summary description for CurrentUser
    /// </summary>
    public class CurrentUser
    {
        public CurrentUser()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        #region propeties
        private string _DisplayName;

        public string DisplayName
        {
            get { return _DisplayName; }
            set { _DisplayName = value; }
        }
        public string Password { get; set; }
        public string UserName { get; set; }
        public Guid UserId { get; set; }
        public int employeeId { get; set; }
        public int DepartmentId { get; set; }
        public string employeeFullName { get; set; }
        public string DepartmentName { get; set; }

        public List<UserSiteMap> SiteMaps { get; set; }

        #endregion
    }

    public class UserSiteMap
    {
        public int Id { get; set; }
        public string Title { get; set; }
        public string Url { get; set; }
        public bool IsLocal { get; set; }
        public string Desc { get; set; }
        public bool CanEdit { get; set; }
        public bool CanAdd { get; set; }
        public bool CanDelete { get; set; }
        public bool CanView { get; set; }
        public string IconUrl { get; set; }
        public bool HasChilds
        {
            get
            {
                return (Childs.Count > 0);
            }
        }
        List<UserSiteMap> _Childs;
        public List<UserSiteMap> Childs
        {
            get
            {
                if (_Childs == null)
                    return _Childs = new List<UserSiteMap>();
                else return _Childs;
            }
        }

        public UserSiteMap FindItem(string itemUrl)
        {
            if (this.Url.Trim().Equals(itemUrl.Trim()))
                return this;
            else
            {
                if (HasChilds)
                {
                    UserSiteMap ortu = null;
                    foreach (var item in Childs)
                    {
                        ortu = FindItem(item,itemUrl);
                        if (ortu != null)
                            break;
                    }
                    return ortu;
                }
                else return null;
            }
        }

         UserSiteMap FindItem(UserSiteMap itemUsersiteMap,string Itemurl)
        {
            if (itemUsersiteMap.Url.Trim().Equals(Itemurl.Trim()))
                return this;
            else
            {
                if (HasChilds)
                {
                    UserSiteMap ortu = null;
                    foreach (var item in Childs)
                    {
                        ortu = FindItem(item, Itemurl);
                        if (ortu != null)
                            break;
                    }
                    return ortu;
                }
                else return null;
            }
        }

    }
}
